package com.xbongbong.saas.script.tempenum;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.help.FormDataFormExplainHelper;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.paas.field.SerialNumberPoJo;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.AssembleEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import com.xbongbong.sys.enums.RoleEnum;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
/**
 * 装配单
 *
 * @author Jian.Wang
 * @version v1.0
 * @date 2019/1/19
 * @since v1.0
 */
@Getter
public enum TempAssembleEnum {
    // 显示模板字段
    BASE_INFO(AssembleEnum.BASE_INFO),
    SHEET_NO(AssembleEnum.SHEET_NO),
    MANAGER_ID(AssembleEnum.MANAGER_ID),
    ASSEMBLE_TIME(AssembleEnum.ASSEMBLE_TIME),
    MEMO(AssembleEnum.MEMO),
    OUT_WAREHOUSE_ID(AssembleEnum.OUT_WAREHOUSE_ID),
    OUT_PRODUCTS(AssembleEnum.OUT_PRODUCTS),
    INTO_WAREHOUSE_ID(AssembleEnum.INTO_WAREHOUSE_ID),
    IN_PRODUCTS(AssembleEnum.IN_PRODUCTS),

    SYSTEM_INFO(AssembleEnum.SYSTEM_INFO),
    CREATOR_ID(AssembleEnum.CREATOR_ID),
    ADD_TIME(AssembleEnum.ADD_TIME),
    UPDATE_TIME(AssembleEnum.UPDATE_TIME),

    OUT_WAREHOUSE_ID_LINKED_TEXT(AssembleEnum.OUT_WAREHOUSE_ID_LINKED_TEXT),
    INTO_WAREHOUSE_ID_LINKED_TEXT(AssembleEnum.INTO_WAREHOUSE_ID_LINKED_TEXT),

    ;

    private AssembleEnum anEnum;

    TempAssembleEnum(AssembleEnum assembleEnum) {
        this.anEnum = assembleEnum;
    }

    public static List<TempAssembleEnum> getAllEnum() {
        java.util.List<TempAssembleEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    /**
     * 初始化装配出入库单的默认编号
     *
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initSheetNo(FieldAttrEntity fieldAttrEntity){
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.ASSEMBLE.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.ASSEMBLE.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(SHEET_NO.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setNoRepeat(1);
        SerialNumberPoJo serialNumberPoJo = InitExplainsHelper.setSerialNumber(SerialNumberEnum.ASSEMBLE_NO);
        fieldAttrEntity.setSerialNumber(serialNumberPoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 出库仓库
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initOutWarehouseId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.WAREHOUSE.getCode());
        fieldAttrEntity.setLinkedText(OUT_WAREHOUSE_ID_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 出库仓库
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initIntoWarehouseId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.WAREHOUSE.getCode());
        fieldAttrEntity.setLinkedText(INTO_WAREHOUSE_ID_LINKED_TEXT.anEnum.getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
    }
    /**
     * 采购退货出库产品
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initOutProducts(FieldAttrEntity fieldAttrEntity) {
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
        //由后端逻辑控制
//        fieldAttrEntity.setNoEditable(1);
    }

    /**
     * 采购退货入库产品
     * @param fieldAttrEntity 字段解释实体--saas专用
     */
    public static void initInProducts(FieldAttrEntity fieldAttrEntity) {
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initAssembleTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setDateType("yyyy-MM-dd");
        fieldAttrEntity.setIsForbidden(0);
    }

    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }

    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initManagerId(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setMultiple(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setRequired(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setAdd(1);
        fieldAttrEntity.setAddAdvanceEnable(1);
        fieldAttrEntity.setShowAdd(1);
        fieldAttrEntity.setRemove(1);
        fieldAttrEntity.setRemoveAdvanceEnable(1);
        fieldAttrEntity.setShowRemove(1);
        fieldAttrEntity.setAddRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.WAREHOUSE_MANAGER));
        fieldAttrEntity.setRemoveRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.WAREHOUSE_MANAGER));
    }
}
